//
//  CommentsCell.m
//  WuJieLive
//
//  Created by iMac on 2017/11/27.
//  Copyright © 2017年 zhk. All rights reserved.
//

#import "CommentsCell.h"

@implementation CommentsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)bindDataWithModel:(CommentModel *)model
{
    [self.userImageView sd_setImageWithURL:[NSURL URLWithString:model.user_portrait]];
    self.userNameLabel.text = model.user_name;
//    model.comment_contents = @"发动机卡拉胶放大来看发动机卡拉胶放大来看发动机卡拉胶放大来看发动机卡拉胶放大来看发动机卡拉胶放大来看发动机卡拉胶放大来看发动机卡拉胶放大来看发动机卡拉胶放大来看";
    self.commentLabel.text = model.comment_contents;
    CGRect frame = self.commentLabel.frame;
    frame.size.height = [model.comment_contents boundingRectWithSize:CGSizeMake(kScreenWidth - 80, MAXFLOAT) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName :FontSize(13)} context:nil].size.height;
    self.commentLabel.frame = frame;
    self.goodsLabel.text = model.goods_spec_name;
    self.timeLabel.text = model.comment_time;
    if (model.pictures.count == 1) {
        self.firstImage.hidden = NO;
        
        [self.firstImage sd_setImageWithURL:[NSURL URLWithString:model.pictures[0]] placeholderImage:[UIImage imageNamed:@"bg"]];
    }else if (model.pictures.count == 2)
    {
        self.firstImage.hidden = NO;
        self.secondImage.hidden = NO;
        
        [self.firstImage sd_setImageWithURL:[NSURL URLWithString:model.pictures[0]] placeholderImage:[UIImage imageNamed:@"bg"]];
        [self.secondImage sd_setImageWithURL:[NSURL URLWithString:model.pictures[1]] placeholderImage:[UIImage imageNamed:@"bg"]];
    }else if(model.pictures.count == 3)
    {
        self.firstImage.hidden = NO;
        self.secondImage.hidden = NO;
        self.thirdImage.hidden = NO;
        
        [self.firstImage sd_setImageWithURL:[NSURL URLWithString:model.pictures[0]] placeholderImage:[UIImage imageNamed:@"bg"]];
        [self.secondImage sd_setImageWithURL:[NSURL URLWithString:model.pictures[1]] placeholderImage:[UIImage imageNamed:@"bg"]];
        [self.thirdImage sd_setImageWithURL:[NSURL URLWithString:model.pictures[2]] placeholderImage:[UIImage imageNamed:@"bg"]];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
